import Taro from '@tarojs/taro'
import { View, Button, Picker } from '@tarojs/components'
import { useState, useEffect } from "react";
import { AtToast,AtActionSheet, AtActionSheetItem, AtForm, AtSwitch  } from "taro-ui"
// import "~taro-ui/dist/style/components/action-sheet.scss";
function Counter() {
    const [count, setCount] = useState(550)
    const [aaa, ssetaa] = useState({})
    const [isOpened, ssisOpened] = useState(false)
    const [isOpened2, ssisOpened2] = useState(false)
    const [selectorChecked, setaaa] = useState('美国')
    const [selector, setselector] = useState(['美国', '中国', '巴西', '日本'])
    useEffect(() => {
        console.log('useEffect')
        // Taro.request({ url: 'https://jsonplaceholder.typicode.com/todos/1' }).then(res => {
        //     console.log(res.data)
        //     setaaa(res.data)
        // })
    }, [])

    const add = () => {
        console.log('add')
        ssisOpened(true)
    }

    const [value, setvalue] = useState(false)
    const handleChange = (value) => {
        setvalue(value, 66  )
    }

    return (
        <View>
            <AtForm>
        <AtSwitch title='开启中' checked={value} onChange={(value) => handleChange(value)} />
      </AtForm>
            <Button type='primary' onClick={() => setCount(count + 1)}>点击数：{count}</Button>
            <Picker mode='selector' range={selector} onChange={(e) => setselector(e.detail.value)}>
                <View className='picker'>
                    当前选择：{selectorChecked}
                </View>
            </Picker>
            <Button className='btn-max-w' plain type='primary' disabled>不可点击的按钮</Button>
            {/* <div onClick={()=> add()}>{aaa?.title}666666</div> */}
            <AtToast isOpened text="1111" ></AtToast>
            <Button onClick={
                () => {
                    Taro.request({ url: 'https://jsonplaceholder.typicode.com/todos/1' }).then(res => {
                        console.log(res.data)
                        setaaa(res.data)
                    })
                }
            }>请求</Button>
            <AtActionSheet isOpened2 cancelText='取消' title='头部标题可以用通过转义字符换行'>
                <AtActionSheetItem>
                    按钮一
                </AtActionSheetItem>
                <AtActionSheetItem>
                    按钮二
                </AtActionSheetItem>
            </AtActionSheet>
        </View>
    )
}

export default Counter